﻿#include "frienddrone.h"

FriendDrone::FriendDrone(QWidget *parent, QString name) : Sprite(parent, name)
{
    this->setFixedSize(pixmap->size()*0.2);
    QVBoxLayout *layout=new QVBoxLayout(this);
    this->widget->setLayout(layout);
    layout->addWidget(closeButton);
    connect(closeButton,&QPushButton::clicked,[=](){
        this->isExist=false;
    });
}

FriendDrone::~FriendDrone()
{
    deleteResouce();
    //free(this);
}
void FriendDrone::mousePressEvent(QMouseEvent *event)
{
    if(!this->widget->isVisible())
        this->widget->show();
    else  this->widget->hide();
    QPushButton::mousePressEvent(event);
    //qDebug()<<"you have push the button";
}

void FriendDrone::deleteResouce()
{
    delete pixmap;
    delete closeButton;
    delete widget;
}
